﻿using Seesmic.Sdp.Extensibility;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Windows;

namespace Seesmic.HelloTipi
{
    public class AccountSidebarAction : TimelineSidebarAction, ISidebarActionGroup, ISidebarAction
    {
        private List<ISidebarAction> _TimelineSidebarItems;
        private HelloTipiAccount _account;

        public AccountSidebarAction(HelloTipiAccount account)
        {
            this._account = account;
            this._TimelineSidebarItems = new List<ISidebarAction>();
        }

        internal bool AddTimelineSidebarItem(ISidebarAction sidebarItem)
        {
            if (!this._TimelineSidebarItems.Contains(sidebarItem))
            {
                this._TimelineSidebarItems.Add(sidebarItem);
                return true;
            }
            return false;
        }

        public HelloTipiAccount Account
        {
            get
            {
                return this._account;
            }         
        }

        public bool CanInvoke
        {
            get
            {
                return true;
            }
        }

        public override DataTemplate Icon
        {
            get
            {
                return HelloTipiPlugin.AccountIcon;
            }
        }

        public override string PersistId
        {
            get
            {
                return string.Format("{0}_{1}", this.Account.Username, base.PersistId);
            }
        }

        public IList<ISidebarAction> SidebarActions
        {
            get
            {
                return this._TimelineSidebarItems;
            }
        }

        public override string Text
        {
            get
            {
                return this.Account.Username;
            }
        }
    }
}

